import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
	
	
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true) {
			String str = br.readLine().trim();
			if(str.equals("0 0")) {
				break;
			}
			StringTokenizer sToken = new StringTokenizer(str, " ");
			int n = Integer.parseInt(sToken.nextToken());
			int k = Integer.parseInt(sToken.nextToken());
			
			if(n == 1) {
				System.out.println(n + " " + k + " " + 1);
			} else {
				int ans = 1;
				for(int i = 2; i <= n; i++) {
					ans = (ans + k % n) % i;
				}
				System.out.println(n + " " + k + " " + ans);
			}
		}
	}

}
